package cn.analysis.project.service.impl;

import cn.analysis.framework.aspectj.lang.annotation.DataSource;
import cn.analysis.framework.aspectj.lang.enums.DataSourceType;
import cn.analysis.project.domain.CivilCode;
import cn.analysis.project.mapper.CivilCodeMapper;
import cn.analysis.project.service.ICivilCodeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/** 行政区划 实现 */
@Service
@DataSource(value = DataSourceType.SLAVE)
public class CiviCodeServiceImpl implements ICivilCodeService {

    @Autowired
    private CivilCodeMapper civilCodeMapper;

    /** 查看所有下级对应的civilcode */
    @Override
    public List<CivilCode> selectCivilCodesByCode(String code) {
        return civilCodeMapper.selectCivilCodesByCode(code);
    }

    /** 通过中文名匹配civilcode */
    @Override
    public List<CivilCode> selectCodeByName(String name) {
        QueryWrapper<CivilCode> wrapper = new QueryWrapper<>();
        wrapper.like("name", name);
        return civilCodeMapper.selectList(wrapper);
    }
}
